import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/Table';
import { render } from '@apps/antd-admin/src/hooks/render/renderUtils';
import { airportList } from '@apps/ant-bus/src/views/business/airport/data/api';

export const columns: BasicColumn[] = [
  {
    title: '商家名称',
    dataIndex: 'shopName',
    width: 100,
  },
  {
    title: '商家图片',
    dataIndex: 'shopImg',
    width: 100,
    customRender: render.renderImage,
  },
  {
    title: '上下架',
    dataIndex: 'isShelf',
    width: 120,
    align: 'center',
  },
  {
    title: '机场',
    dataIndex: 'airportName',
    width: 100,
  },
  {
    title: '创建日期',
    dataIndex: 'createTime',
    width: 100,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'shopName',
    label: '商家名称',
    component: 'Input',
    colProps: { span: 5 },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'airportId',
    label: '机场Id',
    component: 'Input',
    required: false,
    show: false,
  },
  {
    label: '商家名称',
    field: 'shopName',
    component: 'Input',
    required: true,
  },
  {
    label: '营业时间',
    field: 'shopTime',
    component: 'Input',
    required: true,
  },
  {
    label: '门店电话',
    field: 'shopPhone',
    component: 'Input',
    required: true,
  },
  {
    label: '是否上架',
    field: 'isShelf',
    component: 'Select',
    required: true,
    componentProps: {
      options: [
        { label: '不上架', value: 2 },
        { label: '上架', value: 1 },
      ],
    },
  },
  {
    label: '排序',
    field: 'shopSort',
    component: 'InputNumber',
    required: true,
  },
  {
    label: '商家地址',
    field: 'shopAddress',
    component: 'InputTextArea',
    required: true,
  },
  {
    label: '所属机场',
    field: 'airportId',
    component: 'ApiSelect',
    componentProps: {
      api: airportList,
      labelField: 'airportName',
      valueField: 'airportId',
      immediate: true,
      showSearch: true,
    },
  },
  {
    label: '商家图片',
    field: 'shopImg',
    component: 'ImageUpload',
  },
  {
    label: '商家描述',
    field: 'shopDesc',
    component: 'TyEditor',
    required: true,
  },
];
